<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"   prefix="fmt"%>
<%@ include file="index.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="favicon.ico" >
    <link rel="Shortcut Icon" href="favicon.ico" />

    <title>主页</title>
    <meta name="keywords" content="耶回收">
    <meta name="description" content="耶回收">
</head>
<body>

<!--_表格--开始-->
<section class="Hui-article-box">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>
        订单管理
        <span class="c-gray en">&gt;</span>
        到期订单管理
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <div class="Hui-article">
        <article class="cl pd-20">
            <div class="text-c">
            <form action="zldddq" method="post">
				<span class="select-box inline">
				<select name="ghm" class="select">
					<option value="0">订单状态</option>
					<option value="1" <c:if test="${ghm==1}">selected="selected"</c:if>>未还</option>
					<option value="2" <c:if test="${ghm==2}">selected="selected"</c:if>>已还</option>
				</select>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <i class="Hui-iconfont">&#xe665;</i><input type="submit" class="btn btn-success" value="搜索" id="" name="">
                </form>
            </div>
            <div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l">
				<!-- <a class="btn btn-primary radius" data-title="添加资讯" _href="article-add.html" onclick="article_add('添加资讯','article-add.html')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加资讯</a> -->
				<shiro:hasPermission name="order"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a></shiro:hasPermission>
				</span>
                <span class="r">共有<strong>${page.total}</strong>条 数据</span>
            </div>
            <div class="mt-20">
                <table class="table table-border table-bordered table-bg table-hover table-sort">
                    <thead>
                    <tr class="text-c">
                    	<th width="25"><input type="checkbox" name="" value=""></th>
                    	<th width="30">序号</th>
                        <th width="90">订单编号</th>            
                        <th width="80">用户电话</th>
                        <th width="80">租赁时间</th>
                        <th width="120">到期时间</th>
                        <th width="75">订单状态</th>
                    </tr>
                    </thead>
                    <tbody id="tb">
                    <c:forEach items="${page.list }" var="list" varStatus="s"> 
                    <tr class="text-c">
                    	<td ><input type="checkbox" value="${list.oid}" name=""></td>		
                    	<td>${s.count}</td>		
                        <td>${list.oid}</td>
                        <td>${list.phone}</td>
                        <td>${list.time}</td>
                        <td><fmt:formatDate value="${list.ghtime}" pattern="yyyy-MM-dd"/></td>                   
                        
                        <td class="td-status" id="gh" >
	                        <a onclick="change(${list.ghm} ,'${list.oid}')" title="点击修改">
	                        <c:if test="${list.ghm==1}">
	                        	<span class="label label-default radius">未还</span>
	                        </c:if>
	                        <c:if test="${list.ghm==2}">
	                        	<span class="label label-primary radius">已还</span>
	                        </c:if>
	                        </a>
                        </td>
                    </tr>
                    </c:forEach>
                    </tbody>
                </table>
            		<th colspan="12"><p>当前第[${page.pageNum}]页     共${page.pages}页</p>
        				<a href="zldddq?pageNum=1&ghm=${ghm}">首页</a>
        				<c:if test="${page.pageNum > 1 }">
       						<a href="zldddq?pageNum=${page.prePage}&ghm=${ghm}">上一页</a>
       					</c:if>
       					<c:if test="${page.pageNum <= 1 }">
							<a class="right">上一页</a>
						</c:if>
        				<c:if test="${page.pageNum < page.pages}">
        					<a href="zldddq?pageNum=${page.nextPage}&ghm=${ghm}">下一页</a>
        				</c:if>
        				<c:if test="${page.pageNum >= page.pages}">
							<a class="right">下一页</a>
						</c:if>
        				<a href="zldddq?pageNum=${page.pages}&ghm=${ghm}">尾页</a>
        		    </th>
            </div>
        </article> 	
    </div>
</section>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
		 
   function change(ghm , oid){
	   
	   if(ghm==1){
		   $.post("chag",{ghm:2,oid:oid},function(){
			  window.location.href=location.href;
		   })
	   }else{
		   $.post("chag",{ghm:1,oid:oid},function(){
			   window.location.href=location.href;
		   })
	   }
   }
   
   /*批量删除*/
   function datadel(){
	  console.log("-----进入批量删除的方法------");
	  var tds = new Array();
       //获取所有的tr标签元素集合
	   tds=document.getElementById("tb").getElementsByTagName("tr");
		  var td_s = new Array();
		 
		  for(var i=0;i<tds.length;i++){
		  var tdc =tds[i].getElementsByTagName("td")[0].getElementsByTagName("input")[0];
		  var tdcheck =$(tdc);
		  console.log(tdcheck.is(":checked"));
		  if(tdcheck.is(":checked")){
		    //如果td被选中 则td的id值放入数组中
			td_s.push(tdcheck.val());
		    
		 } 
		  } 
	   //判断是否有被选中删除的记录 
	   if(td_s.length>0){
		  console.log(td_s);
		   //发出批量删除ajax 删除请求
		   layer.confirm('确认要删除吗？',{ btn: ["确定","取消"] },function(index){
	           $.ajax({
	               type: 'POST',
	               url: 'deleteZLin',
	               data:{"td_s":td_s},
	               dataType: 'json',
	               success: function(val){
	               	layer.close(index);
	               layer.msg("删除成功",{icon:1,time:2000});
	               	window.location.href = window.location.href;                	
	               },
	               error:function(data) {
	                   console.log(data.msg);
	               },
	           });
	       });
	   }else{ 
		   
		   layer.msg("请选择要删除的数据！",{time:2000});
		 
	   }
	   
   }
   
</script>
</body>
</html>